package cn.itrip.auth.service.impl;

import cn.itrip.auth.service.SmsService;
import com.cloopen.rest.sdk.CCPRestSmsSDK;
import org.springframework.stereotype.Service;

import java.util.HashMap;
@Service
public class SmsServiceImpl implements SmsService {
    @Override
    public void send(String to, String templateId, String[] datas) throws Exception{
        CCPRestSmsSDK smsSDK=new CCPRestSmsSDK();
        smsSDK.init("app.cloopen.com","8883");
        smsSDK.setAccount("8aaf07087d7fb5f6017d8f1c4ccf02b3","81d57b067fde44298bde781bf77a4c6b");
        smsSDK.setAppId("8aaf07087d7fb5f6017d8f1c4e0202ba");
        HashMap<String, Object> map = smsSDK.sendTemplateSMS(to, templateId, datas);
        if("000000".equals(map.get("statusCode")))
            System.out.println("短信发送成功！");
        else
            throw new Exception(map.get("statusCode").toString()+":"+map.get("stuatusMsg").toString());
    }
}
